<?php include "../public/header.php";?>
<?php include "../public/header_edit.php";?>
<body id="optPage">
<form class="layui-form layui-form-pane" id="commentForm" style="padding-bottom: 500px">
    <div class="page-title"><div class="page-title-con"><span id="flowsetname"></span><div class="move_title"></div><?php include "../public/subturn.php";?></div></div>
    <div class="main-container">
        <div class="block-generic">
            <?php include "../public/substt.php";?>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>持证人</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>人员姓名</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="personid" class="layui-input personid" onclick="openPage('../public/choose_person.php?dom=personid&page=cert_employ','80%','80%')">
                            <div class="choose_div" id="personid" key="1"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_person.php?dom=personid&page=cert_employ','80%','80%')">
                                <i class="layui-icon layui-icon-search"></i>
                            </span>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>人员性质</label>
                        <div class="layui-input-block">
                            <select id="nature" name="nature" lay-filter="nature" ></select>
                            <p class="error" id="nature_error" style="margin: 0;"></p>
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>聘费合同信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>合同名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" id="name" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">合同编号</label>
                        <div class="layui-input-block">
                            <input type="text" id="number" readonly autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">签约日期</label>
                        <div class="layui-input-block">
                            <input type="text" name="sign_dt" id="sign_dt" placeholder="请选择" clearable autocomplete="off" class="layui-input bdate_ymd">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>聘用资格</label>
                        <div class="layui-input-block">
                            <div id="qualification"></div>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">聘用渠道</label>
                        <div class="layui-input-block">
                            <div id="channel"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">聘用说明</label>
                        <div class="layui-input-block">
                            <textarea id="employ_explain" name="employ_explain" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">证件用途</label>
                        <div class="layui-input-block">
                            <div id="purpose"></div>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">是否可驻场</label>
                        <div class="layui-input-block">
                            <select class="layui-select" name="iszhu" id="iszhu">
                                <option value="">请选择</option>
                                <option value="是">是</option>
                                <option value="否">否</option>
                            </select>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>聘费支付方式</label>
                        <div class="layui-input-block">
                            <select id="pay_type" name="pay_type" lay-filter="pay_type" ></select>
                            <p class="error" id="pay_type_error" style="margin: 0;"></p>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label" id="money_label"><text>*</text>聘费(元)</label>
                        <div class="layui-input-block">
                            <input type="text" placeholder="请填写" name="money" id="money" clearable autocomplete="off" class="layui-input moneyinput">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">聘费说明</label>
                        <div class="layui-input-block">
                            <textarea id="pin_explain" name="pin_explain" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>聘期开始时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="start_dt" id="start_dt" placeholder="请输入" clearable autocomplete="off" class="layui-input bdate_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>聘期结束时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="end_dt" id="end_dt" placeholder="请输入" clearable autocomplete="off" class="layui-input bdate_ymd">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">项目补贴(元/月)</label>
                        <div class="layui-input-block">
                            <input type="text" name="subsidy" id="subsidy" placeholder="请输入" clearable autocomplete="off" class="layui-input moneyinput">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">出场费(元/次)</label>
                        <div class="layui-input-block">
                            <input type="text" name="out_fee" id="out_fee" placeholder="请输入" clearable autocomplete="off" class="layui-input moneyinput">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">银行账户名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="account" id="account" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">银行账号</label>
                        <div class="layui-input-block">
                            <input type="text" name="account_num" id="account_num" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">开户行</label>
                        <div class="layui-input-block">
                            <input type="text" name="open_bank" id="open_bank" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">备注</label>
                        <div class="layui-input-block">
                            <textarea id="explain" name="explain" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>

            <?php include '../public/flowqita.php'?>
            <?php include '../public/upinfo.php'?>
        </div>
    </div>
</form>
<script>
    $("#commentForm").validate({
        rules: {
            name: {required: true},
            money: {required: true},
            start_dt: {required: true},
            end_dt: {required: true},
        },
        messages:{
            name: {required: "请输入"},
            money: {required: "请输入"},
            start_dt: {required: "请选择"},
            end_dt: {required: "请选择"},
        }
    });

    layui.use(['laytp', 'form'], function() {
        var form = layui.form, layer = layui.layer;
        render_input_attr();

        facade.ajax({type: 'get', url: ask_flowdata_add_cert_employ}).done(function(res){
            if (res.code === 2000) {
                var data = res.data;
                chu_flow_qian(data);

                $("#number").val(data.number);


                xiala_zhan_one_you('nature', res.data.nature);
                xiala_zhan_one_zuo('pay_type', res.data.pay_type);


                xmselect_dan('channel', res.data.channel, '');
                xmselect_duo('qualification', res.data.qualification, '', function (res) {
                    if(res.arr && res.arr.length > 0){
                        $("#qualification").find('xm-select').removeClass('error');
                    }else{
                        $("#qualification").find('xm-select').addClass('error');
                    }
                });
                xmselect_dan('purpose', res.data.purpose, '');

                public_upload_file_load('upload_files', res.data.files);
                render_date();
                render_from();
                initParseMoney();
            }
        });

        form.on('select(nature)', function(data){
            if(data.value == ''){
                $('#nature_error').show().text('请选择');
                $('#nature_error').parent().find('input').addClass('select_error');
            }else{
                $('#nature_error').hide();
                $('#nature_error').parent().find('input').removeClass('select_error');
            }
        });

        form.on('select(pay_type)', function(data){
            if(data.value == ''){
                $('#pay_type_error').show().text('请选择');
                $('#pay_type_error').parent().find('input').addClass('select_error');
            }else{
                $('#pay_type_error').hide();
                $('#pay_type_error').parent().find('input').removeClass('select_error');
            }
        });

        form.on('submit(add)', function(data){
            data.field.isturn = $(this).attr('key') || 0;
            data.field.flowrelas = get_choose_val('flowrelas');
            data.field.advaners = tan_tags_getvalue("#advaners", 'user');
            data.field.nexter = tan_tags_getvalue("#nexter", 'user');
            parseMoney(data);

            data.field.personid = get_choose_val('personid');
            if(data.field.isturn > 0){
                var validRes = $("#commentForm").valid();
                formValid('personid');
                if(data.field.personid == undefined || !data.field.personid){
                    validRes = false;
                }

                if(data.field.nature == ''){
                    $('#nature_error').show().text('请选择');
                    $('#nature_error').parent().find('input').addClass('select_error');
                    validRes = false;
                }else{
                    $('#nature_error').hide();
                    $('#nature_error').parent().find('input').removeClass('select_error');
                }

                if(!data.field.qualification){
                    $("#qualification").find('xm-select').addClass('error');
                    validRes = false;
                }else{
                    $("#qualification").find('xm-select').removeClass('error');
                }

                if(data.field.pay_type == ''){
                    $('#pay_type_error').show().text('请选择');
                    $('#pay_type_error').parent().find('input').addClass('select_error');
                    validRes = false;
                }else{
                    $('#pay_type_error').hide();
                    $('#pay_type_error').parent().find('input').removeClass('select_error');
                }

                if(!validRes){return false;}
            }


            data.field.files = public_upload_file_value('upload_files');
            data = parseMoney(data);
            public_flow_submit(data.field, ask_flowdata_add_cert_employ, ask_flowdata_edit_cert_employ, $(this).attr('but'));
            return false;
        });

    });

</script>
</body>
</html>
